{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>336</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>189</td>\n",
       "      <td>5</td>\n",
       "      <td>0.026455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11</td>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>0.015873</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>16</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>17</td>\n",
       "      <td>2435</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   uid  click_num  buy_num  buy_click_ratio\n",
       "0    3        336        0         0.000000\n",
       "1    4        189        5         0.026455\n",
       "2   11         63        1         0.015873\n",
       "3   16         31        0         0.000000\n",
       "4   17       2435        0         0.000000"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df_user=pd.read_csv('./cache/user_table.csv')\n",
    "df_user.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>196016</th>\n",
       "      <td>649941</td>\n",
       "      <td>110</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196017</th>\n",
       "      <td>649942</td>\n",
       "      <td>51</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196019</th>\n",
       "      <td>649959</td>\n",
       "      <td>23</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196022</th>\n",
       "      <td>649981</td>\n",
       "      <td>48</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196024</th>\n",
       "      <td>649987</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "196016  649941        110        0              0.0\n",
       "196017  649942         51        0              0.0\n",
       "196019  649959         23        0              0.0\n",
       "196022  649981         48        0              0.0\n",
       "196024  649987         31        0              0.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[df_user['buy_num']==0].tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>196025</th>\n",
       "      <td>649988</td>\n",
       "      <td>182</td>\n",
       "      <td>10</td>\n",
       "      <td>0.054945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196026</th>\n",
       "      <td>649989</td>\n",
       "      <td>729</td>\n",
       "      <td>2</td>\n",
       "      <td>0.002743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196027</th>\n",
       "      <td>649990</td>\n",
       "      <td>274</td>\n",
       "      <td>9</td>\n",
       "      <td>0.032847</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196028</th>\n",
       "      <td>649992</td>\n",
       "      <td>131</td>\n",
       "      <td>4</td>\n",
       "      <td>0.030534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196029</th>\n",
       "      <td>649997</td>\n",
       "      <td>82</td>\n",
       "      <td>12</td>\n",
       "      <td>0.146341</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "196025  649988        182       10         0.054945\n",
       "196026  649989        729        2         0.002743\n",
       "196027  649990        274        9         0.032847\n",
       "196028  649992        131        4         0.030534\n",
       "196029  649997         82       12         0.146341"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[df_user['buy_num']!=0].tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>189</td>\n",
       "      <td>5</td>\n",
       "      <td>0.026455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11</td>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>0.015873</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>18</td>\n",
       "      <td>23</td>\n",
       "      <td>2</td>\n",
       "      <td>0.086957</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>19</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>0.008850</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>20</td>\n",
       "      <td>16</td>\n",
       "      <td>2</td>\n",
       "      <td>0.125000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   uid  click_num  buy_num  buy_click_ratio\n",
       "1    4        189        5         0.026455\n",
       "2   11         63        1         0.015873\n",
       "5   18         23        2         0.086957\n",
       "6   19        113        1         0.008850\n",
       "7   20         16        2         0.125000"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>108,857.0000</td>\n",
       "      <td>108,857.0000</td>\n",
       "      <td>108,857.0000</td>\n",
       "      <td>108,857.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>325,246.8951</td>\n",
       "      <td>398.8490</td>\n",
       "      <td>5.3098</td>\n",
       "      <td>0.0309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>187,447.8635</td>\n",
       "      <td>513.0276</td>\n",
       "      <td>7.1412</td>\n",
       "      <td>0.0566</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>4.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>162,916.0000</td>\n",
       "      <td>99.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0070</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>325,808.0000</td>\n",
       "      <td>230.0000</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>0.0156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>486,682.0000</td>\n",
       "      <td>501.0000</td>\n",
       "      <td>6.0000</td>\n",
       "      <td>0.0339</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>649,997.0000</td>\n",
       "      <td>10,122.0000</td>\n",
       "      <td>259.0000</td>\n",
       "      <td>1.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               uid    click_num      buy_num  buy_click_ratio\n",
       "count 108,857.0000 108,857.0000 108,857.0000     108,857.0000\n",
       "mean  325,246.8951     398.8490       5.3098           0.0309\n",
       "std   187,447.8635     513.0276       7.1412           0.0566\n",
       "min         4.0000       1.0000       1.0000           0.0001\n",
       "25%   162,916.0000      99.0000       1.0000           0.0070\n",
       "50%   325,808.0000     230.0000       3.0000           0.0156\n",
       "75%   486,682.0000     501.0000       6.0000           0.0339\n",
       "max   649,997.0000  10,122.0000     259.0000           1.0000"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 输出格式设置，保留四位小数\n",
    "pd.options.display.float_format='{:,.4f}'.format\n",
    "df_user.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>uid</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>60057</th>\n",
       "      <td>199561</td>\n",
       "      <td>6012</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97018</th>\n",
       "      <td>321875</td>\n",
       "      <td>7264</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>192593</th>\n",
       "      <td>638882</td>\n",
       "      <td>6052</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0002</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           uid  click_num  buy_num  buy_click_ratio\n",
       "60057   199561       6012        1           0.0002\n",
       "97018   321875       7264        1           0.0001\n",
       "192593  638882       6052        1           0.0002"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_user[(df_user['buy_num']<2) & (df_user['click_num']>6000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>brand_id</th>\n",
       "      <th>cat_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>621837</td>\n",
       "      <td>10010304</td>\n",
       "      <td>297</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1698431</td>\n",
       "      <td>10012546</td>\n",
       "      <td>271</td>\n",
       "      <td>13.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>653495</td>\n",
       "      <td>10026906</td>\n",
       "      <td>1056</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1426380</td>\n",
       "      <td>10012968</td>\n",
       "      <td>297</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200496</td>\n",
       "      <td>10004565</td>\n",
       "      <td>1056</td>\n",
       "      <td>16.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    spu_id  brand_id  cat_id  click_num  buy_num  buy_click_ratio\n",
       "0   621837  10010304     297    44.0000   0.0000           0.0000\n",
       "1  1698431  10012546     271    13.0000   0.0000           0.0000\n",
       "2   653495  10026906    1056     1.0000   0.0000           0.0000\n",
       "3  1426380  10012968     297     1.0000   0.0000           0.0000\n",
       "4   200496  10004565    1056    16.0000   0.0000           0.0000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#同理统计商品信息\n",
    "df_goods=pd.read_csv('goods_table.csv')\n",
    "df_goods.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>621837</td>\n",
       "      <td>44.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1698431</td>\n",
       "      <td>13.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>653495</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1426380</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>200496</td>\n",
       "      <td>16.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    spu_id  click_num  buy_num  buy_click_ratio\n",
       "0   621837    44.0000   0.0000           0.0000\n",
       "1  1698431    13.0000   0.0000           0.0000\n",
       "2   653495     1.0000   0.0000           0.0000\n",
       "3  1426380     1.0000   0.0000           0.0000\n",
       "4   200496    16.0000   0.0000           0.0000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#针对每一件商品，统计其点击购买\n",
    "df_sp =  df_goods[['spu_id', 'click_num', 'buy_num', 'buy_click_ratio']]\n",
    "df_sp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1731056</td>\n",
       "      <td>387.0000</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>0.0078</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1843018</td>\n",
       "      <td>63.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>462130</td>\n",
       "      <td>14.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1279048</td>\n",
       "      <td>3.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.3333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>161638</td>\n",
       "      <td>95.0000</td>\n",
       "      <td>2.0000</td>\n",
       "      <td>0.0211</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     spu_id  click_num  buy_num  buy_click_ratio\n",
       "15  1731056   387.0000   3.0000           0.0078\n",
       "22  1843018    63.0000   1.0000           0.0159\n",
       "30   462130    14.0000   1.0000           0.0714\n",
       "31  1279048     3.0000   1.0000           0.3333\n",
       "41   161638    95.0000   2.0000           0.0211"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp = df_sp[df_sp['buy_num']>0]#剔除没人买过的商品\n",
    "df_sp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "      <td>234,536.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1,056,104.1906</td>\n",
       "      <td>108.3979</td>\n",
       "      <td>2.4645</td>\n",
       "      <td>0.0691</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>610,254.0032</td>\n",
       "      <td>207.4349</td>\n",
       "      <td>6.8163</td>\n",
       "      <td>0.1137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>5.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>527,495.5000</td>\n",
       "      <td>18.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0156</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1,055,871.5000</td>\n",
       "      <td>46.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1,583,765.2500</td>\n",
       "      <td>113.0000</td>\n",
       "      <td>2.0000</td>\n",
       "      <td>0.0769</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2,114,307.0000</td>\n",
       "      <td>7,705.0000</td>\n",
       "      <td>643.0000</td>\n",
       "      <td>1.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              spu_id    click_num      buy_num  buy_click_ratio\n",
       "count   234,536.0000 234,536.0000 234,536.0000     234,536.0000\n",
       "mean  1,056,104.1906     108.3979       2.4645           0.0691\n",
       "std     610,254.0032     207.4349       6.8163           0.1137\n",
       "min           5.0000       1.0000       1.0000           0.0003\n",
       "25%     527,495.5000      18.0000       1.0000           0.0156\n",
       "50%   1,055,871.5000      46.0000       1.0000           0.0355\n",
       "75%   1,583,765.2500     113.0000       2.0000           0.0769\n",
       "max   2,114,307.0000   7,705.0000     643.0000           1.0000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>spu_id</th>\n",
       "      <th>click_num</th>\n",
       "      <th>buy_num</th>\n",
       "      <th>buy_click_ratio</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>90519</th>\n",
       "      <td>1261881</td>\n",
       "      <td>2,858.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>319064</th>\n",
       "      <td>2063191</td>\n",
       "      <td>2,304.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>392885</th>\n",
       "      <td>1976027</td>\n",
       "      <td>2,683.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>461389</th>\n",
       "      <td>1101741</td>\n",
       "      <td>2,110.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>810397</th>\n",
       "      <td>564449</td>\n",
       "      <td>2,261.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>884540</th>\n",
       "      <td>1044530</td>\n",
       "      <td>2,341.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>916625</th>\n",
       "      <td>385994</td>\n",
       "      <td>2,267.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1156468</th>\n",
       "      <td>1733289</td>\n",
       "      <td>2,814.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1179561</th>\n",
       "      <td>2006587</td>\n",
       "      <td>2,046.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1276865</th>\n",
       "      <td>1278883</td>\n",
       "      <td>2,017.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1561137</th>\n",
       "      <td>1600462</td>\n",
       "      <td>2,026.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0005</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          spu_id  click_num  buy_num  buy_click_ratio\n",
       "90519    1261881 2,858.0000   1.0000           0.0003\n",
       "319064   2063191 2,304.0000   1.0000           0.0004\n",
       "392885   1976027 2,683.0000   1.0000           0.0004\n",
       "461389   1101741 2,110.0000   1.0000           0.0005\n",
       "810397    564449 2,261.0000   1.0000           0.0004\n",
       "884540   1044530 2,341.0000   1.0000           0.0004\n",
       "916625    385994 2,267.0000   1.0000           0.0004\n",
       "1156468  1733289 2,814.0000   1.0000           0.0004\n",
       "1179561  2006587 2,046.0000   1.0000           0.0005\n",
       "1276865  1278883 2,017.0000   1.0000           0.0005\n",
       "1561137  1600462 2,026.0000   1.0000           0.0005"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sp[(df_sp['buy_num']<2) & (df_sp['click_num']>2000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
